package com.it.controller.admin;

import com.it.bean.R;
import com.it.bean.RestStatusEnum;
import com.it.pojo.params.order.AdminOrderQuery;
import com.it.pojo.vo.order.AdminOrderVO;
import  com.it.OrderService;
import com.it.admin.AdminOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/order")
@CrossOrigin
@Api(value = "v1", tags = "订单相关接口")

public class AdminOrderController {

    @Resource
    private AdminOrderService adminOrderService ;

    @PostMapping("")
    @ApiOperation(value = "条件查询订单", notes = "条件查询订单")

    public R<?> list(@RequestBody AdminOrderQuery adminOrderQuery) {
        System.out.println("adminOrderQuery = " + adminOrderQuery);
        Map<String, Object> map = adminOrderService.listOrders(adminOrderQuery);
        return R.success("成功", map);
    }

    /**
     * @return
     */
    @PutMapping("{orderId}")
    @ApiOperation(value = "修改订单状态发货", notes = "修改订单状态发货")
    public R<?> update(@PathVariable("orderId") String orderId) {
        if (orderId == null) {
            return R.error(RestStatusEnum.PARAMS_ERROR);
        }
        return adminOrderService.updateOrderStatus(Long.parseLong(orderId));
    }
}
